﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;

namespace WebApplication.Controls
{
    public partial class UCLoaiSP : System.Web.UI.UserControl
    {
        string ID = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            ID = Request.QueryString["IDLoaiSP"];
            if (!IsPostBack)
            {
                Display();
            }

        }
        private void Display()
        {
            repLoaiSP.DataSource = BLL.LoaiSPBLL.LayTatCa();
            repLoaiSP.DataBind();

        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            repLoaiSP.ItemDataBound += new RepeaterItemEventHandler(repLoaiSP_ItemDataBound);
        }
        protected void repLoaiSP_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            

        }

        protected void repLoaiSP_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                Entities.LoaiSP data = e.Item.DataItem as Entities.LoaiSP;
                string Id = data.IDLoaiSP.ToString();
                HyperLink lnkLoaiSP = (HyperLink)e.Item.FindControl("lnkLoaiSP");
                lnkLoaiSP.Text = data.TenLoaiSP;
                lnkLoaiSP.NavigateUrl = LinkBLL.ToLoaiSP(Id);
                lnkLoaiSP.ToolTip = data.MoTa;
            }
        }
    }
}